home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Telnet / Terminal 2.2 / Project / Sources / XOptions.c < prev    next >
Text File  |  1992-01-17  |  4KB  |  147 lines

  1. /*
  2.     Terminal 2.2
  3.     "XYOptions.c"
  4. */
  5.  
  6. #ifdef THINK_C
  7. #include "MacHeaders"
  8. #endif
  9. #ifdef applec
  10. #pragma load ":(Objects):MacHeadersMPW"
  11. #pragma segment Options
  12. #endif
  13.  
  14. #include "Options.h"
  15. #include "Strings.h"
  16. #include "Utilities.h"
  17. #include "Text.h"
  18. #include "Main.h"
  19. #include "Procedure.h"
  20.  
  21. #define B_OK        1        /* OK button */
  22. #define B_CANCEL    2        /* Cancel button */
  23. #define C_CRC        3        /* X-Modem CRC check box */
  24. #define R_1K_N        4        /* No 1K radio button */
  25. #define R_1K_A        5        /* Automatic 1K radio button */
  26. #define R_1K_CK        6        /* "CK" type 1K radio button */
  27. #define R_BATCH_N    7        /* No batch radio button */
  28. #define R_BATCH_Y    8        /* Y-Modem batch radio button */
  29. #define R_BATCH_R    9        /* RR batch radio button */
  30. #define R_5            10        /* X-Modem timeout 5 seconds radio button */
  31. #define R_10        11        /* X-Modem timeout 10 seconds radio button */
  32. #define R_15        12        /* X-Modem timeout 15 seconds radio button */
  33. #define R_20        13        /* X-Modem timeout 20 seconds radio button */
  34. #define U_TITLELINE    14        /* Underline */
  35. #define T_1K        15        /* 1K frame */
  36. #define U_1K        16
  37. #define T_BATCH        17        /* Batch frame */
  38. #define U_BATCH        18
  39. #define T_TIMEOUT    19        /* Timeout frame */
  40. #define U_TIMEOUT    20
  41.  
  42. static Byte frames[] = { U_1K, U_BATCH, U_TIMEOUT };
  43.  
  44. /* ----- Activate/deactivate XModem options ---------------------------- */
  45.  
  46. static void ActivateX(
  47.     register DialogPtr dialog,
  48.     register Boolean active)
  49. {
  50.     ActivateDeactivate(dialog, R_1K_N, active);
  51.     ActivateDeactivate(dialog, R_1K_A, active);
  52.     ActivateDeactivate(dialog, R_1K_CK, active);
  53. }
  54.  
  55. /* ----- X/Y-Modem options dialog -------------------------------------- */
  56.  
  57. void XYOptions(void)
  58. {
  59.     register DialogPtr dialog;
  60.     register short i;
  61.     register long n;
  62.     register Boolean active;
  63.     short number;
  64.  
  65.     CenterDialog('DLOG', DLOG_XYMODEM);
  66.     if (!(dialog = GetNewDialog(DLOG_XYMODEM, 0, (WindowPtr)-1L)))
  67.         return;
  68.     SetUserItem(dialog, U_TITLELINE, (ProcPtr)DrawUserLine);
  69.     for (i = 0; i < sizeof(frames); i++)
  70.         SetUserItem(dialog, frames[i], (ProcPtr)DrawUserFrame);
  71.     if (Settings.XModemCRC)
  72.         active = TRUE;
  73.     else {
  74.         active = FALSE;
  75.         Settings.XModem1K = 0;
  76.     }
  77.     ActivateX(dialog, active);
  78.     switch(Settings.XModemtimeout) {
  79.         case 5*60:
  80.             i = R_5;
  81.             break;
  82.         case 15*60:
  83.             i = R_15;
  84.             break;
  85.         case 20*60:
  86.             i = R_20;
  87.             break;
  88.         default:
  89.             i = R_10;
  90.     }
  91.     SetRadioButton(dialog, R_5, R_20, i);
  92.     SetRadioButton(dialog, R_1K_N, R_1K_CK, R_1K_N + Settings.XModem1K);
  93.     SetRadioButton(dialog, R_BATCH_N, R_BATCH_R, R_BATCH_N+Settings.batch);
  94.     SetCheck(dialog, C_CRC, Settings.XModemCRC);
  95.     ShowWindow(dialog);
  96.     for (;;) {
  97.         ModalDialog(0, &number);
  98.         switch(number) {
  99.             case B_OK:
  100.                 switch (GetRadioButton(dialog, R_5, R_20)) {
  101.                     case R_5:
  102.                         n = 5*60;
  103.                         break;
  104.                     case R_15:
  105.                         n = 15*60;
  106.                         break;
  107.                     case R_20:
  108.                         n = 20*60;
  109.                         break;
  110.                     default:
  111.                         n = 10*60;
  112.                 }
  113.                 XYModemSetup(
  114.                     GetCheck(dialog, C_CRC),
  115.                     GetRadioButton(dialog, R_1K_N, R_1K_CK) - R_1K_N,
  116.                     GetRadioButton(dialog, R_BATCH_N, R_BATCH_R) -
  117.                         R_BATCH_N,
  118.                     n);    /* Timeout */
  119.             case B_CANCEL:
  120.                 DisposDialog(dialog);
  121.                 return;
  122.             case C_CRC:
  123.                 if (active)
  124.                     SetRadioButton(dialog, R_1K_N, R_1K_CK, R_1K_N);
  125.                 ActivateX(dialog, active = !active);
  126.                 ToggleCheckBox(dialog, number);
  127.                 break;
  128.             case R_1K_N:
  129.             case R_1K_A:
  130.             case R_1K_CK:
  131.                 SetRadioButton(dialog, R_1K_N, R_1K_CK, number);
  132.                 break;
  133.             case R_5:
  134.             case R_10:
  135.             case R_15:
  136.             case R_20:
  137.                 SetRadioButton(dialog, R_5, R_20, number);
  138.                 break;
  139.             case R_BATCH_N:
  140.             case R_BATCH_Y:
  141.             case R_BATCH_R:
  142.                 SetRadioButton(dialog, R_BATCH_N, R_BATCH_R, number);
  143.                 break;
  144.         }
  145.     }
  146. }
  147.